<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/8 0008
  Time: 23:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/tagPage.jsp" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>角色列表</title>
    <meta name="keywords" content="中文"/>
    <meta name="description" content="下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->
    <link href="${baseurl}statics/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->
    <!-- fonts -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/fonts.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/translateelement.css"/>

    <!-- ace styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->
    <!-- 公共的js -->
    <script src="${baseurl}statics/assets/js/common.js"></script>
    <!-- ace settings handler -->

    <script src="${baseurl}statics/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <!--[if lt IE 9]>
    <script src="${baseurl}statics/assets/js/html5shiv.js"></script>
    <script src="${baseurl}statics/assets/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">系统管理</a>
        </li>

        <li>
            <a href="${baseurl}sysRoleController/findAllRole">角色管理</a>
        </li>
        <li class="active">角色列表</li>
    </ul><!-- .breadcrumb -->


</div>

<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <h3 class="header smaller lighter blue">角色列表</h3>
                    <div class="table-header">
                        角色列表信息
                    </div>

                    <div class="table-responsive">

                        <div style="width: 25%;"  class="system_top_l clearfix">
                            <form class="form-search" action="${baseurl}sysRoleController/findAllRole" method="post">
                                <div class="row" style="margin-top: 10px;float: left;">
                                    <div class="col-xs-12 col-sm-8">
                                        <div class="input-group">
                                            <input type="text" class="form-control search-query" name="keywords"
                                                   placeholder="请输入角色名称" value="${keywords}"/>
                                            <span class="input-group-btn">
																		<button type="submit"
                                                                                class="btn btn-purple btn-sm">
																			搜索
																			<i class="icon-search icon-on-right bigger-110"></i>
																		</button>
																	</span>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div style="float: left;margin-top: 10px;" class="system_top_r clearfix">
                            <shiro:hasPermission name="role:add">
                                <div id="inPermission">
                                    <a class="btn btn-purple btn-sm" href="${baseurl}sysRoleController/toAdd"
                                      >添加角色</a>
                                </div>
                            </shiro:hasPermission>
                        </div>
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                               style="margin-top: 20px;">
                            <thead>
                            <tr>
                                <th class="center" style="vertical-align: middle;height: 50px">
                                    <label>
                                        <input type="checkbox" class="ace"/>
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th style="text-align: center;vertical-align: middle;height: 50px">角色id</th>
                                <th style="text-align: center;vertical-align: middle;height: 50px">角色名称</th>
                                <%--<th class="hidden-480">手机号</th>--%>

                                <th style="text-align: center;vertical-align: middle;height: 50px">
                                    <i class="icon-time bigger-110 hidden-480"></i>
                                    修改时间
                                </th>
                                <%--<th class="hidden-480">用户状态</th>--%>

                                <th style="text-align: center;vertical-align: middle;height: 50px">操作</th>
                            </tr>
                            </thead>

                            <tbody>
                            <c:forEach items="${page.records}" var="role">
                                <tr>
                                    <td class="center" style="text-align: center;vertical-align: middle;height: 50px">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>

                                    <td style="text-align: center;vertical-align: middle;height: 50px">
                                        <a href="#">${role.id}</a>
                                    </td>
                                    <td style="text-align: center;vertical-align: middle;height: 50px">${role.roleName}</td>
                                    <%--<td class="hidden-480">${user.userPhone}</td>--%>
                                    <td style="text-align: center;vertical-align: middle;height: 50px"><fmt:formatDate value="${role.updateTime}"
                                                        pattern="YYYY年M月d日 h:mm:ss"></fmt:formatDate></td>

                                    <td style="text-align: center;vertical-align: middle;height: 50px">
                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                            <shiro:hasPermission name="role:update">
                                            <a class="green" href="${baseurl}sysRoleController/toUpdate?roleId=${role.id}" title="修改">
                                                修改
                                            </a>
                                            </shiro:hasPermission>
                                            <shiro:hasPermission name="role:distribution">
                                            <c:if test="${role.id != 1}">
                                                <a class="btn btn-purple btn-sm" href="${baseurl}sysRoleController/findPermission?roleId=${role.id}">分配权限</a>
                                            </c:if>
                                            </shiro:hasPermission>
                                            <shiro:hasPermission name="role:delete">
                                            <a class="red" href="javascript:onclick = del(${role.id});" title="删除">
                                                <i class="icon-trash bigger-130"></i>
                                            </a>
                                            </shiro:hasPermission>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>

                        <jsp:include page="/WEB-INF/jsp/common/pageHelper.jsp"/>

                    </div>
                </div>
            </div>
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${baseurl}statics/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${baseurl}statics/assets/js/bootstrap.min.js"></script>
<script src="${baseurl}statics/assets/js/typeahead-bs2.min.js"></script>


<script src="${baseurl}statics/assets/js/ace-elements.min.js"></script>
<script src="${baseurl}statics/assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">
    function del(id) {
        if(id == 1){
            alert("不能删除超级管理员");
            return false;
        }
        var k = window.confirm("确定是否要删除！");
        if (k) {
            $.ajax({
                url: "${baseurl}sysRoleController/delete",
                data:{"roleId":id},
                type: "post",
                success: function (json) {
                    if(json.code == "0"){
                        alert(json.message);
                        location.reload();
                    }else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }
    jQuery(function ($) {
        var oTable1 = $('#sample-table-2').dataTable({
            "aoColumns": [
                {"bSortable": false},
                null, null, null, null, null,
                {"bSortable": false}
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });
        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table');
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })
</script>
</body>
</html>
